package cn.tedu.mm.basic.dao.persist.repository.impl;

import cn.tedu.mm.basic.dao.persist.mapper.AnnouncementMapper;
import cn.tedu.mm.basic.dao.persist.repository.IAnnouncementRepository;
import cn.tedu.mm.basic.pojo.vo.ListAnnouncementVO;
import cn.tedu.mm.common.pojo.vo.PageData;
import cn.tedu.mm.common.util.PageInfoToPageDataConverter;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AnnouncementRepositoryImpl implements IAnnouncementRepository {
    @Autowired
    private AnnouncementMapper announcementMapper;
    @Override
    public PageData<ListAnnouncementVO> listAnnouncement(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        final List<ListAnnouncementVO> listAnnouncementVOS = announcementMapper.listAnnouncement();
        System.out.println(listAnnouncementVOS);
        final PageInfo<ListAnnouncementVO> pageInfo = new PageInfo<>(listAnnouncementVOS);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }
}
